First working version of the code (Yey!!!!!)