bugfix with nearest-target finding