modified to run on Python27