First version of code