Corrected bugs in brackets and refactored game loop