added error checking for request