A more proper solution for determining the query type