move string hash to proper place
better error handling