refactor generator script for python3