Refactor queries to use member variables