bug fixes. While loop does not execute?