move logic out of main into game class