A new attempt with generics