onhashchange, small refactor