splitted check_matname function