add apply method into grammar/function