added saveResults function