simplified code
make this a python package