modified for python3.3