finding error code generalized and error matrix creation code updated