refactor gameengine.java