pgm function.