change for loops with foreach to work directly on array keys