Refactor dispatcher