Replaced each_with_object with inject to support ruby 1.8 (#59)