Copied code from book, edited slightly so class name is correct. Still needs testing.