added game logic
fixed a bug in game logic