work on sync and writing to db