add condition for $terms (is_array)