fixed game logic / removed repeated code