FIXED some bugs for id validation