fixed code for plot output function