added dispatcher, added main function