Finalize after redirection
Refactor codes