fix in hash calculating function