performance improvements for each loops