Please edit your code and add proper indentation.
The posted code is all to the left which makes it very hard to read the logic.