error handling for submit