A first basic working version of the code