Corrected to support nested lists