handle trailing spaces, empty list.