add before query call back