fixed some bugs in handlenumber()