modernize jquery usage and cleanup logic