making it work in ruby-2.0.0
minor refactor & adaptation to Ruby 2.0