python-script refactored