Made code python3 compatible