add as cast, add flatten