Re-organize the codes