Working version for MS_plot