solve endless loop