refactor gameflow