added empty list handling