Refactored parsing of queries from route and handling of the query form