Added handling of bad rows