moved boiler plate code to a helper method
the action part is handled by an Action/Func