Refactored security group creation