adapted to python3