improve automatic redirecting