fixed a bug introduced when converting to python3