add generalize function for query