The main job of a kidney is to filter toxins and waste products from the blood. In dialysis, the machine takes in blood from the artery and pumps it through a semipermeable membrane. This function is similar to that of the capillaries in the kidney. They allow waste products to filter from the kidneys. The waste excretes into a bag in a manner similar to how the bladder excretes urine from the body. The clean blood pumps back into the body and is carried back to the heart via a vein.