adding guard against potential error with rowMeans(...)