Modified to cater for SQLite implementation