Generate dispatch function scratch