refactored subject and page for subject queries to functions