Algorithm clarification