--- a/resize.c
+++ b/resize.c
@@ -1,4 +1,4 @@
-/* $Id: resize.c,v 1.26 2010-12-06 21:57:56 nicm Exp $ */
+/* $Id: resize.c,v 1.27 2010-12-22 15:36:44 tcunha Exp $ */
 
 /*
  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -52,11 +52,7 @@
 	u_int		 	 i, j, ssx, ssy, has, limit;
 	int		 	 flag;
 
-	for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
-		s = ARRAY_ITEM(&sessions, i);
-		if (s == NULL)
-			continue;
-
+	RB_FOREACH(s, sessions, &sessions) {
 		ssx = ssy = UINT_MAX;
 		for (j = 0; j < ARRAY_LENGTH(&clients); j++) {
 			c = ARRAY_ITEM(&clients, j);
@@ -98,9 +94,8 @@
 		flag = options_get_number(&w->options, "aggressive-resize");
 
 		ssx = ssy = UINT_MAX;
-		for (j = 0; j < ARRAY_LENGTH(&sessions); j++) {
-			s = ARRAY_ITEM(&sessions, j);
-			if (s == NULL || s->flags & SESSION_UNATTACHED)
+		RB_FOREACH(s, sessions, &sessions) {
+			if (s->flags & SESSION_UNATTACHED)
 				continue;
 			if (flag)
 				has = s->curw->window == w;