Changed function to output a struct array instead.