refactor game loop to use environment hash