Added calculate distance method to train