fix nth-child calculation
avoid manipulating an array
fix classname.replace bug when more than 2 classes