restructured the code.