correct the manhattan dist; can speed up using hash table