changed code to work with python 3