full algo part