Setting up main loop