Improving information storage by means of segmented magnetic nanowires