corrected flatten and join, ao