improve python2 compatibility