use a generator in nearest_on_boundary
Revert "use a generator in nearest_on_boundary"

This reverts commit cea097c2b3d4a71a141d07ca4b4cd7a8750527ad.