             send success: 'TodoList updated', 200
 
     dataTreeNode = Tree.dataTree.nodes[params.id]
-    isNewTitle   = body.title? and body.title isnt dataTreeNode.data
-    isNewParent  = body.parent_id? and \
-                        body.parent_id isnt dataTreeNode._parent._id
+    parent_id = body.parent_id
+    title = body.title
+    isNewTitle = title? and title isnt dataTreeNode.data
+    
+    isNewParent = parent_id? and parent_id isnt dataTreeNode._parent._id
 
     if isNewTitle or isNewParent
-        # update the path of the todoList in the tree.
-        # This operation updates the todoList and its children paths and the
-        # tree.
-        Tree.moveOrRenameNode params.id, body.title, body.parent_id, (err) ->
-            newData    = {}
-            isToUpdate = false
-            if isNewTitle
-                newData.title = body.title
-                isToUpdate = true
-            if body.tags
-                newData.tags = body.tags
-                isToUpdate = true
-            if isNewParent
-                newData.parent_id = body.parent_id
-                isToUpdate = true
-            if isToUpdate
-                newData.id = params.id
-                
-                list = new TodoList newData
-                list.updateAttributes newData, callback
-            else
-                callback null
+        Tree.moveOrRenameNode params.id, title, parent_id, (err) ->
+            newData = id: params.id
+            newData.title = body.title if isNewTitle
+            newData.tags = body.tags if body.tags
+            newData.parent_id = body.parent_id if isNewParent
 
-    # neither title nor path is changed, the todoList can be updated directly.
-    else
-        newData    = {}
-        isToUpdate = false
-        if body.tags
-            newData.tags = body.tags
-            isToUpdate = true
-        if isToUpdate
-            newData.id = params.id
             list = new TodoList newData
             list.updateAttributes newData, callback
-        else
-            callback null
+
+    else if body.tags?
+        newData = id: params.id
+        newData.tags = body.tags
+
+        list = new TodoList newData
+        list.updateAttributes newData, callback
+    else
+        callback null
 
 # Destroy todo list and all tasks linked to that list.
 action 'destroy', ->

        else if todoList is null
            send error: 'TodoList not found', 404
        else
            todoList.path = JSON.parse todoList.path
            @todoList = todoList
            next()
, only: ['destroy', 'show']


###*
# Before each todoList list modification current tree is loaded. If it does not
# exist it is created.
###

        else
            next()

    Tree.getOrCreate createTreeCb
, only: ['update', 'destroy', 'create']


### Actions ###
