The code is currently at work, thank you. I'm sure there is an even better way than the way I modified the code per your suggestion since I don't understand all of what is happening or why.
If you or someone else could unpack the while statement it could be greatly appreciated.