re-organize the codes