fix code, major part done, haven't test