modify redirect function