Refactor using jquery DOM traversal methods