fix while bug