split of main loop into new dispatcher class