wouldn't it be simpler if we check if there are classes

if(classes) {
}