Correct implementation with ClassTag