modified to output for spark