fix some bug for auto-complete