Update MainGame.java

Refactored code