Fixed bug with redirecting on Page enter function