use while instead of for