Trying to make it work with generics...
Working version :)