refactored recursive.lua (chapter 2)