fix remaining number logic