Fixed to use the multiple sqlite tables