changed logic of redirectPage