Updated code for python3