reworked completion algorithm