optimized array map and append