Code for ch 3