refactoring of labels code