flatten method added