diff --git a/main.go b/main.go
index 29f18af306873278459d2dafce17099810a05048..72034cf9aa10f1c6a600a801681af297dcb036ec 100644
--- a/main.go
+++ b/main.go
@@ -20,11 +20,11 @@ import (
 	"fmt"
 	"html/template"
 	"log"
-	"net/url"
-	"path"
 	"mime"
 	"net/http"
+	"net/url"
 	"os"
+	"path"
 	"strconv"
 	"strings"
 	"time"
@@ -132,16 +132,20 @@ func errorHandler(errorFilesPath string) func(http.ResponseWriter, *http.Request
 
 		var file string
 		for _, ext := range exts {
-			filePath := fmt.Sprintf("%v/%v%v", errorFilesPath, code, ext)
-			if _, err := os.Stat(file); os.IsNotExist(err) {
-				scode := strconv.Itoa(code)
-				filePath = fmt.Sprintf("%v/%cxx%v", errorFilesPath, scode[0], ext)
-				if _, err := os.Stat(file); os.IsNotExist(err) {
-					continue
-				}
+			var filePath string
+
+			filePath = fmt.Sprintf("%v/%v%v", errorFilesPath, code, ext)
+			if _, err = os.Stat(filePath); err == nil {
+				file = filePath
+				break
+			}
+
+			scode := strconv.Itoa(code)
+			filePath = fmt.Sprintf("%v/%cxx%v", errorFilesPath, scode[0], ext)
+			if _, err = os.Stat(filePath); err == nil {
+				file = filePath
+				break
 			}
-			file = filePath
-			break
 		}
 		if file == "" {
 			log.Printf("unexpected error opening file: %v", err)