I cheated to get the answer but I understand the code