Refactoring: Extracting the DB query to a separate method