create function genQuery for better organizing code