refactor of redirectHandler in router