added a smoothMap function