converted script from python 2 to python 3