Added error handling for update and create