map: using optimized group function and removing thereby unnecessary code