Updating script to reuse branch determination logic, updating echo'd output and fixing a bug in branch evaluation logic