change to use while loop becase for loop will run one time