better handling of decode errors