adaptation to python 3