Revert "while loop causing infinite loop"

This reverts commit 4acfd7e6f8ade9cb533a06059460655ceae794e7.
Revert 40d1529..c12c032

This rolls back to commit 40d1529c924e462a136ab4041779d158a58f0076.
Revert "while loop causing infinite loop"

This reverts commit 4acfd7e6f8ade9cb533a06059460655ceae794e7.