fix integrity check algorithm