  			minercount = AVA2_AVA3_MINERS;
  
  		for (j = minerindex; j < (minerindex + minercount); j++) {
-@@ -821,19 +942,19 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
+@@ -821,19 +946,19 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
  	}
  
  	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {

 		get_work(thr, thr->id); /* Make sure pool is ready */
 
 		pool = current_pool();
@@ -720,15 +841,15 @@ static int64_t avalon2_scanhash(struct thr_info *thr)
 			return 0;
 		}
 

 	avalon2_init_pkg(&pkg, AVA2_P_JOB_ID, 1, 1);
 	while (avalon2_send_pkg(fd, &pkg, thr) != AVA2_SEND_OK)
 		;
@@ -542,7 +604,7 @@ static bool avalon2_detect_one(const char *devpath)
 	struct avalon2_info *info;
 	int ackdetect;
 	int fd;
-	int tmp, i, modular[AVA2_DEFAULT_MODULARS];
+	int tmp, i, j, modular[AVA2_DEFAULT_MODULARS];
 	char mm_version[AVA2_DEFAULT_MODULARS][16];
 
 	struct cgpu_info *avalon2;
@@ -558,24 +620,29 @@ static bool avalon2_detect_one(const char *devpath)
 	}
 	tcflush(fd, TCIOFLUSH);
 
-	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++)
 		modular[i] = 0;
-		strcpy(mm_version[i], AVA2_MM_VERNULL);
-		/* Send out detect pkg */
-		memset(detect_pkg.data, 0, AVA2_P_DATA_LEN);
-		tmp = be32toh(i);
-		memcpy(detect_pkg.data + 28, &tmp, 4);
-
-		avalon2_init_pkg(&detect_pkg, AVA2_P_DETECT, 1, 1);
-		avalon2_send_pkg(fd, &detect_pkg, NULL);
-		ackdetect = avalon2_get_result(NULL, fd, &ret_pkg);
-		applog(LOG_DEBUG, "Avalon2 Detect ID[%d]: %d", i, ackdetect);
-		if (ackdetect != AVA2_P_ACKDETECT)
-			continue;
-		modular[i] = 1;
-		memcpy(mm_version[i], ret_pkg.data, 15);
-		mm_version[i][15] = '\0';
+
+	for (j = 0; j < 2; j++) {
+		for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+			strcpy(mm_version[i], AVA2_MM_VERNULL);
+			/* Send out detect pkg */
+			memset(detect_pkg.data, 0, AVA2_P_DATA_LEN);
+			tmp = be32toh(i);
+			memcpy(detect_pkg.data + 28, &tmp, 4);
+
+			avalon2_init_pkg(&detect_pkg, AVA2_P_DETECT, 1, 1);
+			avalon2_send_pkg(fd, &detect_pkg, NULL);
+			ackdetect = avalon2_get_result(NULL, fd, &ret_pkg);
+			applog(LOG_DEBUG, "Avalon2 Detect ID[%d]: %d", i, ackdetect);
+			if (ackdetect != AVA2_P_ACKDETECT && modular[i] == 0)
+				continue;
+			modular[i] = 1;
+			memcpy(mm_version[i], ret_pkg.data, 15);
+			mm_version[i][15] = '\0';
+		}
 	}
+	avalon2_close(fd);
 	if (!modular[0] && !modular[1] && !modular[2] && !modular[3])
 		return false;
 
@@ -595,28 +662,27 @@ static bool avalon2_detect_one(const char *devpath)
 
 	info = avalon2->device_data;
 
