refactoring for using sqlite to handle completion