First try to convert python script to cython