Converted from Python 2 to 3