restructure code