Combine the class name with this method name and all I can tell is that something is being inserted somewhere without first deciphering the code. And doing so is harder than it ought to be as well. This method is on the scary side with an if in a loop in an if. More than one split should happen here.