better replaceHash implementadion