Edited explanation at the end of the code