Refactor out currentBranch function