my version from chapter 8 of Land of Lisp