making python2 code working on python 3