diff --git a/src/history.c b/src/history.c
index d56cc761f1cfbeb8d28645aa9aa1e34b08846901..5ee5091fe193732cab01caf8c7a8ca00a86641b1 100644
--- a/src/history.c
+++ b/src/history.c
@@ -253,7 +253,7 @@ bool have_statedir(void)
     if (homedir != NULL) {
 	statedir = concatenate(homedir, "/.nano/");
 
-	if (stat(statedir, &dirstat) != 0 && S_ISDIR(dirstat.st_mode))
+	if (stat(statedir, &dirstat) == 0 && S_ISDIR(dirstat.st_mode))
 	    return TRUE;
     }