refactored select query to separate method