Add distance checking