fixed sqlite database corruption