Updated distance solver