Converted code to Python3