implemented basic game loop