Added database integrity check