diff --git a/lex.go b/lex.go
index <HASH>..<HASH> 100644
--- a/lex.go
+++ b/lex.go
@@ -128,25 +128,24 @@ func (l *lexer) errorf(format string, args ...interface{}) stateFn {
 }
 
 func (l *lexer) nextToken() token {
-	if l.eofd {
-		return token{eofType, ""}
-	}
 	if l.peekBuffer != nil {
 		tmp := *l.peekBuffer
 		l.peekBuffer = nil
 		return tmp
 	}
-
+	if l.eofd {
+		return token{eofType, ""}
+	}
 	return <-l.items
 }
 
 func (l *lexer) peekToken() token {
-	if l.eofd {
-		return token{eofType, ""}
-	}
 	if l.peekBuffer != nil {
 		return *l.peekBuffer
 	}
+	if l.eofd {
+		return token{eofType, ""}
+	}
 	tmp := <-l.items
 	l.peekBuffer = &tmp
 	return tmp
Fixed peek to not check if it errored first