Maggie's Fix for distance related bug