working main loop