Adding Adam's code