factor out dispatcher