write integrity checking functions
Merge branch 'integrity'