moved gameLogic code to a factory