Refactored query into 2 smaller methods