use closure instead of a named function