Updated distance to target function