re-arranged some JQuery functions