working on distance measure