Updated refactoring to remove further jQuery dependency