Adapt to python2.7