check if n.loops is NA

table(grepl())[""] returns NA when pattern does not match, so it is better to calculate the term separately and check wether it is NA or not. This happens when sequence.structure does not contain any "TL".