added compatibility with Python 3