added flatten scripts