wrap this whole thing as a function on syncService?