Rewrote as library