Added compatibility with Python3