refactor using jQuery.