fixing bug where results were being overwritten