Restructure the code