fixed nesting bug