Rewrote some things into jQuery