tweak foreach_feature to minimize time complexity