fix boundary_end in case of recursion