Minor refactoring of getRunLength()