Fixed invalid handling of empty lists