fixed error handling of invalid requests