started algorithm for replacing dummy materials with real materials