better handling of sqlite3 database