addes bases and distance check