Changed the flow of page generation