Create granulate function with output arguments