moved distance check to a class variable