Rewrite to handle wildcrad edge cases.