Made compatible with Python 3