On the transition from deflagration to detonation