new versoin using log for detection error