This works with Ruby 1.8 and 1.9+, it is also a lot nicer