fixed the redirect bug