fixes off-by-one error in add_error.R