temp fix for pgdata, move stuff into functions for organization