correct dist calculation