changed 7b functions to include for loops