Making code compatible with 3.X.X Python