Pull out query logic into module
fix pager