refactor dispatch method