ported to Python 3