Making main logic of dispatcher.