straight-forward implementation in recursion