cleanup declaration and code in dispatcher