#27 refactoring function for generating new.py