adapt to python3 and code format.