merge Matt's array codec mechanism