7th Iteration

Made repeated code into a function