Added handling of an empty list in the do.