making some changes
sqlite rewrite
Refactoring of DB rewrite