[fix] test array before foreach