diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c
index 35ffb6c..d5b4622 100644
--- a/contrib/cube/cube.c
+++ b/contrib/cube/cube.c
@@ -1506,19 +1506,15 @@ cube_coord(PG_FUNCTION_ARGS)
 	NDBOX	   *cube = PG_GETARG_NDBOX(0);
 	int			coord = PG_GETARG_INT16(1);
 
-	if ((coord > 0) && (coord <= 2*DIM(cube)))
-	{
-		if IS_POINT(cube)
-			PG_RETURN_FLOAT8( (cube)->x[(coord-1)%DIM(cube)] );
-		else
-			PG_RETURN_FLOAT8( (cube)->x[coord-1] );
-	}
-	else
-	{
+	if (coord <= 0 || coord > 2 * DIM(cube))
 		ereport(ERROR,
-					(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
-					 errmsg("Cube index out of bounds")));
-	}
+				(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
+				 errmsg("Cube index out of bounds")));
+
+	if (IS_POINT(cube))
+		PG_RETURN_FLOAT8(cube->x[(coord-1) % DIM(cube)]);
+	else
+		PG_RETURN_FLOAT8(cube->x[coord-1]);
 }
 
 
@@ -1538,25 +1534,26 @@ cube_coord_llur(PG_FUNCTION_ARGS)
 	NDBOX	   *cube = PG_GETARG_NDBOX(0);
 	int			coord = PG_GETARG_INT16(1);
 
-	if ((coord > 0) && (coord <= DIM(cube)))
-	{
-		if IS_POINT(cube)
-			PG_RETURN_FLOAT8( (cube)->x[coord-1] );
-		else
-			PG_RETURN_FLOAT8( Min((cube)->x[coord-1], (cube)->x[coord-1+DIM(cube)]) );
-	}
-	else if ((coord > DIM(cube)) && (coord <= 2*DIM(cube)))
+	if (coord <= 0 || coord > 2 * DIM(cube))
+		ereport(ERROR,
+				(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
+				 errmsg("Cube index out of bounds")));
+
+	if (coord <= DIM(cube))
 	{
-		if IS_POINT(cube)
-			PG_RETURN_FLOAT8( (cube)->x[(coord-1)%DIM(cube)] );
+		if (IS_POINT(cube))
+			PG_RETURN_FLOAT8(cube->x[coord - 1]);
 		else
-			PG_RETURN_FLOAT8( Max((cube)->x[coord-1], (cube)->x[coord-1-DIM(cube)]) );
+			PG_RETURN_FLOAT8(Min(cube->x[coord - 1],
+								 cube->x[coord - 1 + DIM(cube)]));
 	}
 	else
 	{
-		ereport(ERROR,
-					(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
-					 errmsg("Cube index out of bounds")));
+		if (IS_POINT(cube))
+			PG_RETURN_FLOAT8(cube->x[(coord - 1) % DIM(cube)]);
+		else
+			PG_RETURN_FLOAT8(Max(cube->x[coord - 1],
+								 cube->x[coord - 1 - DIM(cube)]));
 	}
 }
 
