re-organize codes