Added comments and explanations. Now the code is easier to read