improved comments and nesting