A method of milking a group of dairy animals by an automatic milking system, the group including at least two subgroups. The method has a number of steps. In one step, a dairy animal that presents itself for a milking is identified. Subsequently, a decision is taken about whether or not the dairy animal should be milked at that moment. If milking is desirable and the dairy animal belongs to the first subgroup, a teat cleaning treatment is carried out prior to the start of the milking. During the teat cleaning treatment, at least one teat of the dairy animal is cleaned. Upon identification of a dairy animal from the second subgroup, a limitation for a teat cleaning treatment is issued by a control device.