initial KvcFun code (chapter 7)