updated the code to work with python3