added proper ordering to plotting