helpers and main recursion outline