refactoring someone's game code and doing some learning