improved for different ruby implementation