refactor query_helper module