Optimized game and added some error handling