Made the code compatible with python 3