Fixing equivalent detection algorithm