kwapply as a macro