made the code python 3 compatible