added error handling for post request