Made code compatible for ruby 1.8.7 (jruby 1.6)