converted from python 2 to python 3