source code modernized for Python 3