Removed grep & sed from branch command - solved using PHP functions