added game logic, fixed bugs