added check for backward branching

untested