corrected error handling in ...read_distances