Fixed bug with improper nesting generated