Rewrote in JQuery