iteration and pointer problems