API adapted for python 3