Updated with the required code.

Not sure if I'm doing this right. But hopefully this works.