updated logic to exclude some errors