update immutable with higher order functions