Added loops for subjects and pages