Fixing bug of the detection.