Working for 2 levels, but not for arbitrary levels