Remove recursion

Small fix to allow more complex scenarios.