update flatten functionalities