modified to python2.7