updated isValidQuery() - added all command checks in single match