Minor refactoring and added JQuery