Added try/except around detection.