added branching functionality