fixed plot function