fix recursion issue
more general recursive splitting