Refactor getLengthClassIds()