Updated the server so it handles invalid data without crashing