added pure python version