fixed bugs on redirecting