Replaced while condition + updates
KMS-3488 #time 3h
Code review updates
KMS-3488
Merge pull request #1596 from kaltura/IX-9.19.1-KMS-3488-script-fix2

IX-9.19.1-KMS-3488-script-fix2