Code that is still messy, but actually works (on ruby 1.9 only)