BUG commenting out a while loop that seems to be causing problems