smarter recursion. fixes #34