made casting of primitives more generic