improve compile and runtime type checking