Added check for script running from remote stream