Now works properly with a list as input.