revised change detection algorithm