Adding For instead of While loop