Refactoring of labels code