added sg creation code