Rewrote code from scratch