minor change for running at ruby 1.9

code.chars.length works on ruby 2.0, but not works on ruby 1.9.