Adding the Loops into the code