keep track of leg order
deleted unnecessary method
refactered countExcludingNullValues
created distanceTolerance constant
return early after error