diff --git a/src/action-log.cc b/src/action-log.cc
index cf5156a..6d0c48b 100644
--- a/src/action-log.cc
+++ b/src/action-log.cc
@@ -20,50 +20,110 @@
  */
 
 #include "action-log.h"
+#include <action-item.pb.h>
 
 using namespace boost;
 using namespace std;
 
 ActionLog::ActionLog (const std::string &path, const std::string &localName)
-  : SyncLog (path)
-  , m_localName (localName)
+  : SyncLog (path, localName)
 {
 }
 
+tuple<sqlite3_int64, sqlite3_int64, sqlite3_int64>
+ActionLog::GetExistingRecord (const std::string &filename)
+{
+  // check if something already exists
+  sqlite3_stmt *stmt;
+  int res = sqlite3_prepare_v2 (m_db, "SELECT version,device_id,seq_no FROM ActionLog WHERE filename=? ORDER BY version DESC,device_id DESC LIMIT 1", -1, &stmt, 0);
+
+  if (res != SQLITE_OK)
+    {
+      BOOST_THROW_EXCEPTION (Error::Db ()
+                             << errmsg_info_str ("Some error with AddActionUpdate"));
+    }
+
+  sqlite3_bind_text (stmt, 1, filename.c_str (), filename.size (), SQLITE_STATIC);
+  if (sqlite3_step (stmt) == SQLITE_ROW)
+    {
+      // with parent with version number + 1
+      sqlite3_int64 version = sqlite3_column_int64 (stmt, 0) + 1;
+      sqlite3_int64 parent_device_id = sqlite3_column_int64 (stmt, 1);
+      sqlite3_int64 parent_seq_no = sqlite3_column_int64 (stmt, 0);
+
+      sqlite3_finalize (stmt);
+      return make_tuple (version, parent_device_id, parent_seq_no);
+    }
+
+  sqlite3_finalize (stmt);
+  return make_tuple ((sqlite3_int64)0, (sqlite3_int64)-1, (sqlite3_int64)-1);
+}
+
 // local add action. remote action is extracted from content object
 void
 ActionLog::AddActionUpdate (const std::string &filename,
                             const Hash &hash,
-                            const std::string &atime, const std::string &mtime, const std::string &ctime,
+                            time_t atime, time_t mtime, time_t ctime,
                             int mode)
 {
   int res = sqlite3_exec (m_db, "BEGIN TRANSACTION;", 0,0,0);
+  
+  sqlite3_int64 seq_no = GetNextLocalSeqNo ();
+  sqlite3_int64 version = 0;
+  sqlite3_int64 parent_device_id = -1;
+  sqlite3_int64 parent_seq_no = -1;
 
-  // sqlite3_stmt *stmt;
-  // res += sqlite3_prepare_v2 (m_db, "SELECT version,device_id,seq_no FROM ActionLog WHERE filename=? ORDER BY version DESC,device_id DESC LIMIT 1", -1, &stmt, 0);
+  sqlite3_int64 action_time = time (0);
+  
+  tie (version, parent_device_id, parent_seq_no) = GetExistingRecord (filename);
+  
+  sqlite3_stmt *stmt;
+  sqlite3_prepare_v2 (m_db, "INSERT INTO ActionLog "
+                      "(device_id, seq_no, action, filename, version, action_timestamp, "
+                      "file_hash, file_atime, file_mtime, file_ctime, file_chmod, "
+                      "parent_device_id, parent_seq_no) "
+                      "VALUES (?, ?, ?, ?, ?, datetime(?, 'unixepoch'),"
+                      "        ?, datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), ?,"
+                      "        ?, ?)", -1, &stmt, 0);
 
-  // if (res != SQLITE_OK)
-  //   {
-  //     BOOST_THROW_EXCEPTION (Error::Db ()
-  //                            << errmsg_info_str ("Some error with AddActionUpdate"));
-  //   }
+  sqlite3_bind_int64 (stmt, 1, m_localDeviceId);
+  sqlite3_bind_int64 (stmt, 2, seq_no);
+  sqlite3_bind_int   (stmt, 3, 0);
+  sqlite3_bind_text  (stmt, 4, filename.c_str (), filename.size (), SQLITE_TRANSIENT);
+  sqlite3_bind_blob  (stmt, 5, hash.GetHash (), hash.GetHashBytes (), SQLITE_TRANSIENT);
 
-  // sqlite3_bind_text (stmt, 1, filename.c_str (), -1);
-  // if (sqlite3_step (stmt) == SQLITE_ROW)
-  //   {
-  //     // with parent
-  //     sqlite3_int64 version = sqlite3_value_int64 (stmt, 0) + 1;
-  //     sqlite3_int64 device_id = sqlite3_value_int64 (stmt, 1);
-  //     sqlite3_int64 seq_no = sqlite3_value_int64 (stmt, 0);
+  sqlite3_bind_int64 (stmt, 6, action_time);
+  
+  sqlite3_bind_int64 (stmt, 7, atime);
+  sqlite3_bind_int64 (stmt, 8, mtime);
+  sqlite3_bind_int64 (stmt, 9, ctime);
+  sqlite3_bind_int   (stmt, 10, mode);
 
-      
-  //   }
-  // else
-  //   {
-  //     // without parent
-      
-  //   }
+  if (parent_device_id > 0 && parent_seq_no > 0)
+    {
+      sqlite3_bind_int64 (stmt, 11, parent_device_id);
+      sqlite3_bind_int64 (stmt, 12, parent_seq_no);
+    }
+  else
+    {
+      sqlite3_bind_null (stmt, 11);
+      sqlite3_bind_null (stmt, 12);
+    }
+  
+  sqlite3_step (stmt);
 
+  // missing part: creating ContentObject for the action !!!
+
+  ActionItem item;
+  item.set_action (ActionItem::UPDATE);
+  item.set_filename (filename);
+  item.set_version (version);
+  item.set_timestamp (action_time);
+  item.set_file_hash (hash.GetHash (), hash.GetHashBytes ());
+  // item
+  
+  sqlite3_finalize (stmt); 
+                          
   res += sqlite3_exec (m_db, "END TRANSACTION;", 0,0,0);
 }
 
