rewrite integrity check