reimplement using sqlite.