Made code Python3 compatible