Added save to db logic