Fixing the type checking of generic for