Hello.
It might help you if you can trace your program using a paper and pencil. Run your program and simultaneously trace it on the paper.
You will end up knowing where exactly you are making...