refactoring find query