diff --git a/docker-compose/grafana/dashboards/archiver_timescale.json b/docker-compose/grafana/dashboards/archiver_timescale.json
index ab0c177d8fdcd5ed5358ec68d8b627e0a59cf559..fbeeb125b5c4767ba584dd5ec7bdda3901e3ae7b 100644
--- a/docker-compose/grafana/dashboards/archiver_timescale.json
+++ b/docker-compose/grafana/dashboards/archiver_timescale.json
@@ -245,7 +245,7 @@
           "hide": false,
           "metricColumn": "none",
           "rawQuery": true,
-          "rawSql": "SELECT\n  temp_time AS \"time\",\n  temperature[1] as \"temp[1]\",\n  temperature[2] as \"temp[2]\",\n  temperature[2] as \"temp[3]\",\n  temperature[2] as \"temp[4]\",\n  temperature[2] as \"temp[5]\",\n  temperature[2] as \"temp[6]\",\n  temperature[2] as \"temp[7]\",\n  temperature[2] as \"temp[8]\",\n  temperature[2] as \"temp[9]\",\n  temperature[2] as \"temp[10]\",\n  temperature[2] as \"temp[11]\",\n  temperature[2] as \"temp[12]\",\n  temperature[2] as \"temp[13]\",\n  temperature[2] as \"temp[14]\",\n  temperature[2] as \"temp[15]\",\n  temperature[2] as \"temp[16]\"\nFROM sdp_masked_temp\nWHERE\n  $__timeFilter(temp_time)\nORDER BY temp_time",
+          "rawSql": "SELECT\n  temp_time AS \"time\",\n  temperature[1] as \"temp[1]\",\n  temperature[2] as \"temp[2]\",\n  temperature[3] as \"temp[3]\",\n  temperature[4] as \"temp[4]\",\n  temperature[5] as \"temp[5]\",\n  temperature[6] as \"temp[6]\",\n  temperature[7] as \"temp[7]\",\n  temperature[8] as \"temp[8]\",\n  temperature[9] as \"temp[9]\",\n  temperature[10] as \"temp[10]\",\n  temperature[11] as \"temp[11]\",\n  temperature[12] as \"temp[12]\",\n  temperature[13] as \"temp[13]\",\n  temperature[14] as \"temp[14]\",\n  temperature[15] as \"temp[15]\",\n  temperature[16] as \"temp[16]\"\nFROM sdp_masked_temp_values\nWHERE\n  $__timeFilter(temp_time)\nORDER BY temp_time",
           "refId": "B",
           "select": [
             [
diff --git a/docker-compose/timescaledb/resources/05_lofar_views.sql b/docker-compose/timescaledb/resources/05_lofar_views.sql
index 82aa8e5de360b434ecf081d1b02c000dff5d50f7..f28f0efc7d0deb80aa345a04b5c7854b9b0732fb 100644
--- a/docker-compose/timescaledb/resources/05_lofar_views.sql
+++ b/docker-compose/timescaledb/resources/05_lofar_views.sql
@@ -33,22 +33,7 @@ t.value_r as "temperature",
 m.value_r as "mask"
 from sdp_fpga_temp as t
 inner join sdp_tr_fpga_mask as m
-on time_bucket('1 second',t.time) = time_bucket('1 second',m.time) 
-/* Replace if possible with SQL loop */
-where m.value_r[1]=true and
-m.value_r[2]=true and
-m.value_r[3]=true and
-m.value_r[4]=true and
-m.value_r[5]=true and
-m.value_r[6]=true and
-m.value_r[7]=true and
-m.value_r[8]=true and
-m.value_r[9]=true and
-m.value_r[10]=true and
-m.value_r[11]=true and
-m.value_r[12]=true and
-m.value_r[13]=true and
-m.value_r[14]=true and
-m.value_r[15]=true and
-m.value_r[16]=true
-order by t."time" ;
+on time_bucket('1 second',t.time) = time_bucket('1 second',m.time)
+inner join generate_series(1,16) gs
+on m.value_r[gs]=true
+order by t."time";