Moved security group preprocessing logic to a separate method