Merge "Refactors common scope id setup code into utility function"