create hook for query altering