Converted the code to python3