Refactor branching to assignment