DB Error checking code added