fixed foreach loop to fetch pages from class