finish type checking implementation