Added distance check.