 # NFT Rarities and DNA layerpercent

Hello everyone,

I’m making an NFT generator with the moralis Template from this repo: https://github.com/ashbeech/moralis-mutants-nft-engine
I’m a bit stuck because i have added more rarities with layerpercent, but it only renders one rarity.
I think it has to do with the DNA but i don’t understand how to add the rarity layers to the DNA in index.js plz help.

Here is the part of the code i think i need to edit:

``````// create a dna based on the available layers for the given rarity
// use a random part for each layer
const createDna = (_layers, _rarity) => {
let randNum = [];
let _rarityWeight = rarityWeights.find((rw) => rw.value === _rarity);
_layers.forEach((layer) => {
let num = Math.floor(
Math.random() * layer.elementIdsForRarity[_rarity].length
);
if (_rarityWeight && _rarityWeight.layerPercent[layer.id]) {
// if there is a layerPercent defined, we want to identify which dna to actually use here (instead of only picking from the same rarity)
let _rarityForLayer = getRandomRarity(
_rarityWeight.layerPercent[layer.id]
);
num = Math.floor(
Math.random() * layer.elementIdsForRarity[_rarityForLayer].length
);
randNum.push(layer.elementIdsForRarity[_rarityForLayer][num]);
} else {
randNum.push(layer.elementIdsForRarity[_rarity][num]);
}
});
return randNum;
};
``````

It seems that i have to set the elements, but in the example they only use 1,1.
I don’t understand how these elements work. have been playing around with the settings but not sure about the logic.

`````` // create required weights
// for each weight, call 'addRarity' with the id and from which to which element this rarity should be applied
let rarityWeights = [
/*