some parts changed to enable running it by python2.7 and python3.3