Refactor redirect and render methods