type checking implementation