fixed redir function