finish conversion to sqlite. now need to fix sorting issue