I tried to reorganize the code.