Implemented sync to db