edited subtraction loop