This is the commented version of the solution