removed debug print
moved logic from script into library
flake8