fixed handling of empty lists