Added flatten support for the chain