clean code of thead.c