use while instead of for loop for array example