changed loops to use enumerators