Refactor label functionality