replace func with map