implement map using fold