added pickle function to save results