Added comments explaining the code