fixed db write error