replaced map with more appropriate each