Fix casting for primitive type