Rewrote as a native C extension