refactored game functionality