# CodeCop Warning AA0181
The FindSet() or Find() methods must be used only in connection with the Next() method.
## Description
Avoid getting the dataset when an enumeration is not used, which will decrease performance.
## Reason for the rule
If you use `FindSet()` or `Find()` you must have a `Next()` method. Otherwise, you are wasting CPU and bandwidth since multiple records are loaded but you only use one.
## Bad code example
```al
codeunit 1 MyCodeunit
{
   var
      customer: Record Customer;

   procedure Foo()
   begin
      if customer.FindFirst() then
         repeat
         ...
         until customer.Next() = 0;
      end;
}
```
## Good code example
```al
codeunit 1 MyCodeunit
{
   var
      customer : Record Customer;

   procedure Foo()
   begin
      if customer.FindSet() then
         repeat
         ...
         until customer.Next() = 0;
      end;
}
```
## Related information
CodeCop Analyzer<codecop>
Get Started with AL<../devenv-get-started>
Developing Extensions<../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0181, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/codecop-aa0181/
