Implemented the back functionality for the Back buttons.