added plots, distance calculation