added waitForDigit function
fixed a compile error