added compatibility with python 3