added a dictionary to function and completed loop process