redirect function fix