Added 400 response code when a query is invalid