added diff function and started main loop