fixed cardetect bug