Move functions to jQuery plugins