First version of the code