changed db save function