refactored into a jquery plugin