fix a bug while input head is empty