change butterfly detection to run in test cases