added game loop logic