fix type checking code, fix regression in MongoDB