Fixed nesting functions