Change to recursive version

Previous non-recursive version can't process 'a*aa' and 'aa'