Fixed off-by-one error in counting commands