implement arrays encode