refactored game controller