changed plot function