reorganize the code.