Rewritten the jquery as a plugin