Moved functions outside jQuery object