fix saving data in db