Restructure code