refactored queries