Fixed compatibility with Python2