Move event listening and cookie storing outside tablesorter