I have added in the procedure along with a working for loop