fixed sqlite writing