fix redirect function beug