Converted to python 3, using 2to3