updated logic to account for 2 errors in a row