complete code

First version of the code