Moved SQLite logic to its own class