added the code explanation