1st attempt

no idea about the recursion… maybe I just need a break…
if the recursion works, part 2. with the flags should be trivial…