diff --git a/flash2d/src/options-sphere/IO_vtu_stacked.F90 b/flash2d/src/options-sphere/IO_vtu_stacked.F90
index 30612ad55fc489ab520652d2dcdaff0bff508d82..8b102f7ad2d9e6ac9157b51394cfc4f4d1298da5 100644
--- a/flash2d/src/options-sphere/IO_vtu_stacked.F90
+++ b/flash2d/src/options-sphere/IO_vtu_stacked.F90
@@ -441,18 +441,17 @@ SUBROUTINE plot_vtu(p_mesh, c_filename, &
   END IF
 
   ! Write the variable belonging to the tetradra.
-#if defined VTU_OUTPUT2D || defined VTU_OUTPUTSPH || defined VTU_OUTPUT2D
   IF(PRESENT(i_celldata) .AND. PRESENT(p_celldata)) THEN
+#if defined VTU_OUTPUT2D || defined VTU_OUTPUTSPH || defined VTU_OUTPUT2D
     DO i_cnt = 1, i_celldata
       CALL write_vtu_data(i_fhandle, p_celldata(i_cnt))
     END DO
-  END IF
 #elif defined VTU_OUTPUTSTC
   ! at this time we assign the same cell values to the whole column of stacked cells
-  ALLOCATE(r_stcval(1,i_numberofvtucells), stat=i_alct)
-  IF(i_alct /= 0) THEN
-	CALL grid_error(c_error='[plot_vtu]: could not allocate aux. stc values arrays')
-  END IF
+    ALLOCATE(r_stcval(1,i_numberofvtucells), stat=i_alct)
+    IF(i_alct /= 0) THEN
+	  CALL grid_error(c_error='[plot_vtu]: could not allocate aux. stc values arrays')
+    END IF
     DO i_cnt = 1, i_celldata
       DO i_hcnt=1,i_numberofcells
         i_stcbeg = (i_hcnt-1)*(i_lay-1)+1
@@ -463,10 +462,11 @@ SUBROUTINE plot_vtu(p_mesh, c_filename, &
       p_stcnodedata(1)%c_name = p_celldata(i_cnt)%c_name
       p_stcnodedata(1)%i_size = p_celldata(i_cnt)%i_size
       p_stcnodedata(1)%p_vdata=>r_stcval
-      CALL write_vtu_data(i_fhandle, p_celldata(i_cnt))
+      CALL write_vtu_data(i_fhandle, p_stcnodedata(1))
     END DO
     DEALLOCATE(r_stcval)
 #endif
+  END IF
 
   ! write the end of cell data and the footer.
   WRITE(i_fhandle, *) '</CellData>'