correct detection logic