Made code compatible with python3