refactored game logic into module