refactor: decreased nesting level