added compatibility with python 2