fixing bugs for python 3