replaced map function