refactor redirect mode