fix nesting bug