Rewrote all logic