added the code for finding the branch sum