fix: prevent infinite loops when executing scripts