fixed funct to support python 3.xx