Refactored checkIfWebViewCanGoForwardsOrBackwards method