add flatten.rb