Use foreach loop when possible for clarity and fence-port error elimination