The present invention, relates to separating a first quantity of milk drawn from a milking animal in an automatic milking machine from a second quantity of milk drawn from a milking animal in said milking machine. Comprising the steps of milking an animal using said automatic milking machine, collecting a small representative amount of said milk during said milking, analysing at least a part of said small representative amount of milk using an on-line cell counter for counting the number of cells in said milk, and operating a valve depending on the counted number of cells so that if the counted number of cells are below a threshold said milk is collected in a first container and if said counted number of cells are equal to or above said threshold said milk are directed to either a drain or a second container.