Added main loop