Fix goBack() function and refactoring.