Created a function to manipulate loops