this higher order functional composition is making my brain hurt