Erlang implementation of PGM