separated generate class from main program and added docstring