final version of the code compiling all the data