diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c
index 48574a4772d6d19654ce536adf1e917926f9efc4..8e191959454291095080315b316c22edb4dc39a4 100644
--- a/apps/app_authenticate.c
+++ b/apps/app_authenticate.c
@@ -126,9 +126,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
 			/* Compare against a fixed password */
 			if (!strcmp(passwd, arglist.password))
 				break;
-		}
-
-		if (ast_test_flag(&flags,OPT_DATABASE)) {
+		} else if (ast_test_flag(&flags,OPT_DATABASE)) {
 			char tmp[256];
 			/* Compare against a database key */
 			if (!ast_db_get(arglist.password + 1, passwd, tmp, sizeof(tmp))) {