more updates to optimize cython code