Use foreach key rather than i