Working version where it stops if you get too close