method to find the closest good capsule.