delete function and some code clean