hash: move duplicated code into functions