change branching so that recursion is possible