revised logic for change detection, more in keeeping with jQuery practice