prevent endless loop on script