new plot function. fixed index