Now writes results to database