Refactor the code updating labels