adopted for python2