Adding ability to write to db
Added save function