diff --git a/tools/check_seapp.c b/tools/check_seapp.c
index 1022cbd485ce2353d024d8de9731d1afa372091d..a7de7a2d2d949e4ade6f09e3df717c59707e9060 100644
--- a/tools/check_seapp.c
+++ b/tools/check_seapp.c
@@ -742,7 +742,7 @@ static rule_map *rule_map_new(kvp keys[], size_t num_of_keys, int lineno,
 
 			/* Only assign key name to map name */
 			if (strcasecmp(k->key, x->name)) {
-				if (i == KVP_NUM_OF_RULES) {
+				if (j == KVP_NUM_OF_RULES - 1) {
 					log_error("No match for key: %s\n", k->key);
 					goto err;
 				}