added missing +1 to error detection code