diff --git a/compressed_sensing.ipynb b/compressed_sensing.ipynb
index b667aedc88543713979fab02b897590842b39920..3bcbd85dad231a43971d9e66ae63e6dc4b609743 100644
--- a/compressed_sensing.ipynb
+++ b/compressed_sensing.ipynb
@@ -83,8 +83,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:13.168903Z",
-     "start_time": "2021-02-08T13:51:11.526672Z"
+     "end_time": "2021-02-08T20:33:06.173184Z",
+     "start_time": "2021-02-08T20:33:04.512214Z"
     }
    },
    "outputs": [],
@@ -92,7 +92,7 @@
     "import os\n",
     "import pandas as pd\n",
     "import numpy as np\n",
-    "from itertools import combinations\n",
+    "from itertools import combinations, product\n",
     "from time import time\n",
     "import matplotlib.pyplot as plt \n",
     "from sklearn.linear_model import Lasso\n",
@@ -130,7 +130,7 @@
    "metadata": {},
    "source": [
     "# Get the data\n",
-    "Let us load the data from the NOMAD Archive and the atomicfeaturespackage. It consists of RS-ZB energy differences (in eV/atom) of the 82 octet binary compounds, structure objects containing the atomic positions of the materials and properties of the atomic constituents. The following atomic features are considered:\n",
+    "Let us load the data from the NOMAD Archive and the atomicfeaturespackage. It consists of RS-ZB energy differences (in eV/atom) of the 82 octet binary compounds, structural information (e.g. atomic positions) of the materials, and properties of the atomic constituents. The following atomic features are considered:\n",
     "\n",
     "<div >\n",
     "   <ul>\n",
@@ -150,8 +150,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.037772Z",
-     "start_time": "2021-02-08T13:51:13.170622Z"
+     "end_time": "2021-02-08T20:33:08.427703Z",
+     "start_time": "2021-02-08T20:33:06.175593Z"
     }
    },
    "outputs": [],
@@ -185,6 +185,23 @@
     "        max=200)\n",
     "    return query\n",
     "\n",
+    "def write_xyz(df):\n",
+    "    for compound, (A, B, pos, lat) in df[['A', 'B', 'atomic_positions', 'lattice_vectors']].iterrows():\n",
+    "        lat_x, lat_y, lat_z = lat\n",
+    "        atoms = [A, B]\n",
+    "        file = open(\"data/compressed_sensing/structures/\"+compound+\".xyz\", \"w\")\n",
+    "        file.write (\"%d\\n\\n\"%32)\n",
+    "        for i, j, k, n in product(range(3), range(3), range(3), range(2)):\n",
+    "            xyz = pos[n].copy()\n",
+    "            xyz += i*lat_x\n",
+    "            xyz += j*lat_y\n",
+    "            xyz += k*lat_z\n",
+    "            file.write(atoms[n])\n",
+    "            file.write(\"\\t%f\\t%f\\t%f\\n\" % (xyz[0],\n",
+    "                                           xyz[1],\n",
+    "                                           xyz[2]))                  \n",
+    "        file.close()\n",
+    "\n",
     "def get_target(query):\n",
     "    \n",
     "    path_structure = './data/compressed_sensing/structures/'\n",
@@ -199,38 +216,40 @@
     "            \"space_group\": calculation.section_system[0].section_symmetry[0].space_group_number,\n",
     "            \"energy\": calculation.section_single_configuration_calculation[0].energy_total.magnitude,\n",
     "            'compound': calculation.section_system[0].chemical_composition_reduced,\n",
+    "            \"atomic_positions\": calculation.section_system[0].atom_positions.magnitude,\n",
+    "            \"lattice_vectors\": calculation.section_system[0].lattice_vectors.magnitude,\n",
     "            },\n",
     "            ignore_index=True\n",
     "        )\n",
-    "        atoms = [atom_labels[0], atom_labels[1]]\n",
-    "        # positions are converted into AA using a scale factor\n",
-    "        scale_factor = 10**10\n",
-    "        positions = calculation.section_system[0].atom_positions\n",
-    "        lat_x, lat_y, lat_z = calculation.section_system[0].lattice_vectors.magnitude * scale_factor\n",
-    "        file = open(\"data/compressed_sensing/structures/\"+df_target.iloc[-1]['compound']+\".xyz\", \"w\")\n",
-    "        file.write (\"%d\\n\\n\"%32)\n",
-    "        for i in [0,1,2]:\n",
-    "            for j in [0,1,2]:\n",
-    "                for k in [0,1,2]:\n",
-    "                    for n in range(2):\n",
-    "                        xyz = calculation.section_system[0].atom_positions[n].magnitude * scale_factor\n",
-    "                        xyz += i*lat_x\n",
-    "                        xyz += j*lat_y\n",
-    "                        xyz += k*lat_z\n",
-    "                        file.write(atoms[n])\n",
-    "                        file.write(\"\\t%f\\t%f\\t%f\\n\" % (xyz[0],\n",
-    "                                                       xyz[1],\n",
-    "                                                       xyz[2]))\n",
-    "        file.close()\n",
-    "        \n",
+    "\n",
     "    df_RS = df_target.query('space_group==225 or space_group==221').set_index('compound').sort_index()\n",
     "    df_ZB = df_target.query('space_group==216 or space_group==227').set_index('compound').sort_index()\n",
+    "    df_RS['struc_type'] = 'RS'\n",
+    "    df_ZB['struc_type'] = 'ZB'\n",
     "    df_target = df_RS[['A','B']]\n",
     "    df_target['energy_diff']=(df_RS['energy']-df_ZB['energy'])/2\n",
-    "    df_target['min_struc_type']=np.where(df_RS['energy']<df_ZB['energy'],'RS','ZB')\n",
-    "\n",
-    "    # convert J in eV \n",
+    "    #df_target['min_struc_type']=np.where(df_RS['energy']<df_ZB['energy'],'RS','ZB')\n",
+    "    \n",
+    "    mins = np.where(df_RS['energy'] < df_ZB['energy'], \n",
+    "              #    [df_RS['atomic_positions'], df_RS['lattice_vectors']], [df_ZB['atomic_positions'], df_ZB['lattice_vectors']]\n",
+    "                  df_RS[['struc_type', 'atomic_positions', 'lattice_vectors']].T, \n",
+    "                  df_ZB[['struc_type', 'atomic_positions', 'lattice_vectors']].T\n",
+    "                 )\n",
+    "    df_mins = pd.DataFrame(mins.T, columns=['min_struc_type', 'atomic_positions', 'lattice_vectors',],\n",
+    "                          index=df_target.index\n",
+    "                          )\n",
+    "\n",
+    "    df_target = pd.concat([df_target, df_mins], axis=1)\n",
+    "   \n",
+    "    # convert J in eV and m in AA\n",
     "    df_target['energy_diff'] *= J\n",
+    "    df_target[['atomic_positions', 'lattice_vectors']] *= 10**10\n",
+    "    \n",
+    "    \n",
+    "    # write structures (atomic_positions, lattice_vectors) into xyz files\n",
+    "    # to be used by the visualizer later\n",
+    "    write_xyz(df_target)\n",
+    "    \n",
     "    return df_target[['A', 'B', 'energy_diff', 'min_struc_type']]\n",
     "\n",
     "# get data (chemical formulas and RS-ZB energy difference) from query\n",
@@ -244,8 +263,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.060958Z",
-     "start_time": "2021-02-08T13:51:16.040921Z"
+     "end_time": "2021-02-08T20:33:08.464082Z",
+     "start_time": "2021-02-08T20:33:08.429950Z"
     },
     "scrolled": true
    },
@@ -272,8 +291,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.080154Z",
-     "start_time": "2021-02-08T13:51:16.062309Z"
+     "end_time": "2021-02-08T20:33:08.497905Z",
+     "start_time": "2021-02-08T20:33:08.466110Z"
     }
    },
    "outputs": [],
@@ -298,8 +317,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.141626Z",
-     "start_time": "2021-02-08T13:51:16.081628Z"
+     "end_time": "2021-02-08T20:33:08.577514Z",
+     "start_time": "2021-02-08T20:33:08.499974Z"
     }
    },
    "outputs": [],
@@ -326,8 +345,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.546500Z",
-     "start_time": "2021-02-08T13:51:16.143452Z"
+     "end_time": "2021-02-08T20:33:09.184095Z",
+     "start_time": "2021-02-08T20:33:08.579531Z"
     }
    },
    "outputs": [],
@@ -353,8 +372,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.551139Z",
-     "start_time": "2021-02-08T13:51:16.548048Z"
+     "end_time": "2021-02-08T20:33:09.190366Z",
+     "start_time": "2021-02-08T20:33:09.186009Z"
     }
    },
    "outputs": [],
@@ -378,8 +397,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.620249Z",
-     "start_time": "2021-02-08T13:51:16.552600Z"
+     "end_time": "2021-02-08T20:33:09.254875Z",
+     "start_time": "2021-02-08T20:33:09.193573Z"
     },
     "scrolled": true
    },
@@ -421,8 +440,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.626622Z",
-     "start_time": "2021-02-08T13:51:16.621742Z"
+     "end_time": "2021-02-08T20:33:09.260671Z",
+     "start_time": "2021-02-08T20:33:09.256261Z"
     }
    },
    "outputs": [],
@@ -457,8 +476,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.656484Z",
-     "start_time": "2021-02-08T13:51:16.628554Z"
+     "end_time": "2021-02-08T20:33:09.292113Z",
+     "start_time": "2021-02-08T20:33:09.262056Z"
     },
     "scrolled": true
    },
@@ -472,8 +491,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:16.763864Z",
-     "start_time": "2021-02-08T13:51:16.657819Z"
+     "end_time": "2021-02-08T20:33:09.428263Z",
+     "start_time": "2021-02-08T20:33:09.294657Z"
     },
     "scrolled": true
    },
@@ -506,8 +525,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:37.834144Z",
-     "start_time": "2021-02-08T13:51:16.765421Z"
+     "end_time": "2021-02-08T20:33:31.391117Z",
+     "start_time": "2021-02-08T20:33:09.430197Z"
     },
     "scrolled": false
    },
@@ -542,8 +561,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:38.104687Z",
-     "start_time": "2021-02-08T13:51:37.835766Z"
+     "end_time": "2021-02-08T20:33:31.696678Z",
+     "start_time": "2021-02-08T20:33:31.392682Z"
     }
    },
    "outputs": [],
@@ -596,8 +615,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:38.110486Z",
-     "start_time": "2021-02-08T13:51:38.106011Z"
+     "end_time": "2021-02-08T20:33:31.705234Z",
+     "start_time": "2021-02-08T20:33:31.698594Z"
     }
    },
    "outputs": [],
@@ -637,8 +656,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:38.479613Z",
-     "start_time": "2021-02-08T13:51:38.111880Z"
+     "end_time": "2021-02-08T20:33:32.080607Z",
+     "start_time": "2021-02-08T20:33:31.706951Z"
     },
     "scrolled": true
    },
@@ -657,8 +676,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:38.766814Z",
-     "start_time": "2021-02-08T13:51:38.481195Z"
+     "end_time": "2021-02-08T20:33:32.459091Z",
+     "start_time": "2021-02-08T20:33:32.082282Z"
     }
    },
    "outputs": [],
@@ -701,8 +720,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:39.113981Z",
-     "start_time": "2021-02-08T13:51:38.769152Z"
+     "end_time": "2021-02-08T20:33:32.840916Z",
+     "start_time": "2021-02-08T20:33:32.461049Z"
     }
    },
    "outputs": [],
@@ -727,8 +746,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:39.375223Z",
-     "start_time": "2021-02-08T13:51:39.115648Z"
+     "end_time": "2021-02-08T20:33:33.163048Z",
+     "start_time": "2021-02-08T20:33:32.843504Z"
     },
     "scrolled": true
    },
@@ -759,8 +778,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:44.105352Z",
-     "start_time": "2021-02-08T13:51:44.087496Z"
+     "end_time": "2021-02-08T20:33:33.181713Z",
+     "start_time": "2021-02-08T20:33:33.164677Z"
     }
    },
    "outputs": [],
@@ -795,8 +814,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:50.268397Z",
-     "start_time": "2021-02-08T13:51:44.988511Z"
+     "end_time": "2021-02-08T20:33:39.353216Z",
+     "start_time": "2021-02-08T20:33:33.183541Z"
     },
     "scrolled": false
    },
@@ -852,8 +871,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:50.737037Z",
-     "start_time": "2021-02-08T13:51:50.270139Z"
+     "end_time": "2021-02-08T20:33:39.816501Z",
+     "start_time": "2021-02-08T20:33:39.355058Z"
     },
     "scrolled": false
    },
@@ -901,14 +920,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Firstly the atomic coordinates of all compounds are stored in a .xyz file for the successive visualization."
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Below the plot containing all octet binary materials, shown in the coordinate reference system given by the SISSO descriptors. By hovering over a point in the plot, information regarding that compound is displayed. By clicking a point, an interactive 3D visualization of the most stable structure will be displayed below the plot. To facilitate comparison between different materials, we make available two separate viewers. The specific viewer to be employed for visualization can be selected with a check box placed on top-right of each visualizer. Once a compound is selected from the plot, the marker on the plot changes shape accordingly to a marker that is specific of the viewer and whose shape is shown next to the checkbox. The name of the compound viewed is shown on top of the visualizer, and it is also possible to modify the name in the text box with the name of another compound, which can be displayed by clicking the \"Display\" button. Consequently, the new compound is also marked on the plot, that allows to easily identify the position of each compound in the plot. \n",
+    "Below the plot containing all octet binary materials, shown in the coordinate reference system given by the SISSO descriptors. By hovering over a point in the plot, information regarding that compound is displayed. By clicking a point, an interactive 3D visualization of the most stable structure will be displayed below the plot. To facilitate comparison between different materials, we make available two separate viewers. The specific viewer to be employed for visualization can be selected with a check box placed on top-right of each visualizer. Once a compound is selected from the plot, the marker on the plot changes shape accordingly to a marker that is specific of the viewer and whose shape is shown next to the checkbox. The name of the compound viewed is shown on top of the visualizer, and it is also possible to modify the name in the text box with the name of another compound, which can be displayed by clicking the \"Display\" button. Consequently, the new compound is also marked on the plot, that allows to easily identify the position of each compound in the plot. Note that the structures of all compounds were stored in a .xyz file at the beginning of the tutorial, i.e. using the function 'write_xyz'.\n",
     "\n",
     "The markers represent the compounds and their colors the reference energy differences. How well does the descriptor separate the compounds with respect to their crystal structure?"
    ]
@@ -918,8 +930,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:51:51.399756Z",
-     "start_time": "2021-02-08T13:51:50.738969Z"
+     "end_time": "2021-02-08T20:33:40.462699Z",
+     "start_time": "2021-02-08T20:33:39.820979Z"
     },
     "scrolled": false
    },
@@ -949,8 +961,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:05:52.104347Z",
-     "start_time": "2021-02-08T13:05:52.050Z"
+     "end_time": "2021-02-08T20:11:40.454034Z",
+     "start_time": "2021-02-08T20:11:38.163588Z"
     }
    },
    "outputs": [],
@@ -970,8 +982,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:05:52.105156Z",
-     "start_time": "2021-02-08T13:05:52.054Z"
+     "end_time": "2021-02-08T20:12:25.769881Z",
+     "start_time": "2021-02-08T20:11:40.457817Z"
     },
     "scrolled": true
    },
@@ -1010,8 +1022,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:05:52.106474Z",
-     "start_time": "2021-02-08T13:05:52.057Z"
+     "end_time": "2021-02-08T20:12:25.856700Z",
+     "start_time": "2021-02-08T20:12:25.773032Z"
     }
    },
    "outputs": [],
@@ -1032,8 +1044,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:05:52.107446Z",
-     "start_time": "2021-02-08T13:05:52.060Z"
+     "end_time": "2021-02-08T20:12:25.941698Z",
+     "start_time": "2021-02-08T20:12:25.873313Z"
     },
     "scrolled": true
    },
@@ -1112,8 +1124,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:05:52.108447Z",
-     "start_time": "2021-02-08T13:05:52.063Z"
+     "end_time": "2021-02-08T20:12:25.957117Z",
+     "start_time": "2021-02-08T20:12:25.943995Z"
     }
    },
    "outputs": [],
@@ -1131,8 +1143,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:05:52.109346Z",
-     "start_time": "2021-02-08T13:05:52.066Z"
+     "end_time": "2021-02-08T20:16:14.007806Z",
+     "start_time": "2021-02-08T20:12:25.961463Z"
     },
     "scrolled": true
    },
@@ -1156,8 +1168,8 @@
    "execution_count": null,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-08T13:05:52.110132Z",
-     "start_time": "2021-02-08T13:05:52.068Z"
+     "end_time": "2021-02-08T20:16:14.107587Z",
+     "start_time": "2021-02-08T20:16:14.013568Z"
     }
    },
    "outputs": [],
@@ -1173,13 +1185,6 @@
     "show_scatter_plot(xs, ys, data_point_labels=data_point_labels, \n",
     "                  x_label='E_diff_DFT', y_label='E_diff_predicted', legend=legend, unit='eV/atom')"
    ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
   }
  ],
  "metadata": {