reorganize the code structure