new version of cythonized code