Modified to run in python3 and python2