diff --git a/lib/gfx/gfx.c b/lib/gfx/gfx.c
index 72a5d67f0191b78563725255521227396b799c88..55f1debf584f7df765e71015cf2f792628286ab8 100644
--- a/lib/gfx/gfx.c
+++ b/lib/gfx/gfx.c
@@ -86,17 +86,25 @@ void gfx_puts(
 	Color fg,
 	Color bg
 ) {
+	// iterate over the string
 	while (*str) {
-		gfx_putchar(font, r, x, y, *str, fg, bg);
-		str++;
-
-		x += font->Width;
-		if (x >= r->width) {
+		// if the current position plus the width of the next character
+		// would bring us outside of the display ...
+		if ((x + font->Width) > r->width) {
+			// ... we move down a line before printing the character
 			x = 0;
 			y += font->Height;
 		}
+		// if the line is outside the display we return
 		if (y >= r->height)
 			return;
+
+		// now print the character
+		gfx_putchar(font, r, x, y, *str, fg, bg);
+		str++;
+
+		// move along on the x axis to get the position of the next character
+		x += font->Width;
 	}
 }