Better written using foreach()