reorganized code.