created another for loop and then gave it conditions to break