ported to python 3