flatten nested arrays