I'm not sure if I understand this correctly, so I have made some changes on line 7-14.