Convert code to Python3