Stopped infinite loop, but branching still needs work