Added database write
Stable with DB