Refactored dom manipulations to use jQuery