recursive, uses closures