update type checking; throw exceptions when type-checking fails.