improve Num calculating logic