Switched to iterative writing of results (to avoid large collection)
Minor edit to function description