converted from python 2 to 3