refactoring
more refactoring, and converted DOM manipulation to jQuery api