refactored gamestate mechanism