Moved the functionality for goBack to a seperate method to simplify it