added check for empty list.