ported to Python3