now adding comments and documenting the code