script converted to python
script rewritten in python