Refactor queries into a separate module