redid the code introduced while loops