fixed it, probably

sometimes it really helps to write and explain an algo step-by-step