added error checking for bad http request