dao query refactor