Implement map algorithm.