This version corresponds to adding theoretical stuff. Some bugs were also fixed in the previous code