Refactored While to For Iterator to fix bug.