added redirect function and fixed error in getPage method