Updated detection logic.