Switch to foreach method to eliminate extra loop.