fix for generic cast typesafety