Re-factor the query table to be a directive.