big update converting to flattened array