Added max_terms option for more control