fixed bugs in computing centroid and the hash key