Update the code refactored
Coment the objectives of the functions