inprogress ... work on pg file writing