isolated the saveHash function