added basical mechanism for the game loop