reduce type checking code