Modernized. Should work on newer versions of Ruby now