implements #44. Returning a bad request error instead of an invalid query needs still to be done