do flatmap manually