refactor code to go back to original path