refactoring gamelayer