refactor Hash generator loop