Resolving "Cannot read property "top" of null" error when not hashtag exists in the URL on page load