adding dispatch function