general helper for all type of query precessing