fixed some bugs and improved game logic