Tested and fixed code to work with game-framework