fixing bug in number of materials