Implement `map` function