re-organize code2