write as clss , optimize the sturct of code