first stab at making this a jQuery plugin too