fix some bug,optimize performance