Explanation of the code