added loop nesting counter