adding error_index as a trait
updated all code so it is 1-indexed