moving this out of the loop should be more efficient.