Added new checks on inserts and updates