Restruct code structure