Adding the code from COT 3011.