rewrote pgen