Updated Fig 3.27 code to use fn and match and put them in module.