modify flatten function ; using concat