you could println your variables each step of the way, and see what is going on...