Refactored the relational query into separate method