Added functionfot compute distance