improved checkIntegrity method