Making the code more scalable
Changed toPage2 to prevPage etc...