fixed underflow bug