fixed distance calculations and initialization
fixed distance calculations and initialization