add automatic type deduction to dispatch function