Added pgm output function