fix saving in database