changes for python 3 TODO fix to work with python 2 as well