Fixing bug with nesting multiple levels