refactored dispatcher