changed sync to use db