FAIMS-248: fixing bug with calculating distance