Implemented the Zin algorithm.