Restructured the code.