refacoring using closures [Nikos M.]