Could move this outside the loop for performance.