Added main loop cap