added database write