code clean and some error deal