cleaned up labeling code