made various improvements to the code and game logic