extract_labels function

Extract labels