restruct the code