Modified to support python 3