move code to chapter12