error fix in calcLinearDistance