implemeted a loop version of lab 1