this code works, three segments, at least once.