function calcDistance added