addded another if statement in the function redirect(n)