added game loop with basic error handling