added L distance check