Switching to JQuery selectors and restructuring