reworked function ...read_distances, removed flags (compiler error)