maths are working, loop not correct