Use apply to call function on block execution