fixed issue in the while