prblem 6 seems off at the last element