almost works in py3, works in py2