refactor main code into gameClass