Changed redirect function