starting to refactor code in generate-pbp.py file